﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Reglas_Negocio;
using Entidades;

namespace Control_Evaluacion
{
    public partial class frmCatDocIdentifica : Form
    {
        public frmCatDocIdentifica()
        {
            InitializeComponent();
        }

        private void tsbtn_add_cat_document_Click(object sender, EventArgs e)
        {
            try
            {
                if (txt_nom_doc_iden.TextLength>0)
                {                    
                    cat_doc_identificacion tbDocIden = new cat_doc_identificacion();
                    tbDocIden.Nom_cat_doc_iden = txt_nom_doc_iden.Text;
                    tbDocIden.Id_cat_doc_iden =Convert.ToInt32( lbl_id_identi.Text);

                    cat_doc_identificacionBuilder.GrabarViaSql(tbDocIden);
                    MessageBox.Show("Registro realizado con exito", "Catalogo Documentos");
                    this.Close();
                }
            }
            catch (Exception)
            {

                throw;
            }
        }

        private void frmCatDocIdentifica_Load(object sender, EventArgs e)
        {
            cargar_datos();
        }

        void cargar_datos()
        {
            dgvCatDocumentos.DataSource = cat_doc_identificacionBuilder.ListarTodos_Alias("");
        }

        private void dgvCatDocumentos_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                lbl_id_identi.Text = dgvCatDocumentos.CurrentRow.Cells[0].Value.ToString();
                txt_nom_doc_iden.Text = dgvCatDocumentos.CurrentRow.Cells[1].Value.ToString();
            }
        }
      }
}
